﻿using System;
using System.Windows.Media;
using System.Windows.Resources;
using Microsoft.Xna.Framework.Audio; // For SoundEffect

namespace IWantIn
{
    public static class SoundEffects
    {
        public static void Initialize()
        {
            StreamResourceInfo info;

            info = App.GetResourceStream(new Uri("Audio/moo.wav", UriKind.Relative));
            Moo = SoundEffect.FromStream(info.Stream);

            info = App.GetResourceStream(new Uri("Audio/mooShake.wav", UriKind.Relative));
            MooShake = SoundEffect.FromStream(info.Stream);

            info = App.GetResourceStream(new Uri("Audio/baa.wav", UriKind.Relative));
            Baa = SoundEffect.FromStream(info.Stream);

            info = App.GetResourceStream(new Uri("Audio/baaShake.wav", UriKind.Relative));
            BaaShake = SoundEffect.FromStream(info.Stream);

            info = App.GetResourceStream(new Uri("Audio/meow.wav", UriKind.Relative));
            Meow = SoundEffect.FromStream(info.Stream);

            info = App.GetResourceStream(new Uri("Audio/meowShake.wav", UriKind.Relative));
            MeowShake = SoundEffect.FromStream(info.Stream);

            CompositionTarget.Rendering += delegate(object sender, EventArgs e)
            {
                // Required for XNA Sound Effect API to work
                Microsoft.Xna.Framework.FrameworkDispatcher.Update();
            };

            // Call also once at the beginning
            Microsoft.Xna.Framework.FrameworkDispatcher.Update();
        }

        public static SoundEffect Moo { get; private set; }
        public static SoundEffect MooShake { get; private set; }
        public static SoundEffect Baa { get; private set; }
        public static SoundEffect BaaShake { get; private set; }
        public static SoundEffect Meow { get; private set; }
        public static SoundEffect MeowShake { get; private set; }
    }
}
